package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.dao.AdminPlusDao;
import com.example.dao.AssessorResultDao;
import com.example.dao.FileDao;
import com.example.entity.FinalPage;
import com.example.entity.StudentInformation;
import com.example.service.AdminPlusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminPlusServiceImpl extends ServiceImpl<AdminPlusDao, StudentInformation> implements AdminPlusService {

    @Autowired
    AdminPlusDao dao;

    @Autowired
    FileDao fileDao;

    @Autowired
    AssessorResultDao resultDao;


    @Override
    public IPage<StudentInformation> getPage(Integer currentPage, Integer pageSize, StudentInformation info) {
        LambdaQueryWrapper<StudentInformation> lqw = new LambdaQueryWrapper<>();
        lqw.like(info.getStudentId()!=null, StudentInformation::getStudentId, info.getStudentId());
        lqw.like(info.getName()!=null, StudentInformation::getName, info.getName());
        lqw.like(info.getPhone()!=null, StudentInformation::getPhone, info.getPhone());
        lqw.like(info.getGreenCode()!=null, StudentInformation::getGreenCode, info.getGreenCode());

        IPage page = new Page(currentPage, pageSize);
        dao.selectPage(page, lqw);
        return page;

    }

    @Override
    public IPage<StudentInformation> getFinalPage(Integer currentPage, Integer pageSize, StudentInformation info) {
        return  null;

    }

    @Override
    public List<FinalPage> getData(int current, int size) {

        return fileDao.getData(current, size);
    }

    @Override
    public boolean setResult(String sid, String s) {
        return resultDao.updateBySid(sid, s);
    }


}
